using UnityEngine;
using System.Collections;

public class playerBehaviorScript : MonoBehaviour
{
	
	public int maxHealth = 100;
	public int curHealth = 100;
	public float healthBarLength;
	public int healthChange=20;
	public float playerJumpMagnitude = 1.5f;
	// Use this for initialization
	void Start ()
	{
		healthBarLength = (Screen.width / 4.0f) + 100f;
	}
	
	// Update is called once per frame
	void Update ()
	{ 
		jump();
	}
	
	public void jump()
	{
		if (Input.GetButtonDown ("Jump")) {
			animation.
			transform.Translate (0, playerJumpMagnitude, 0);
		} else if (Input.GetButtonUp ("Jump")) {
			transform.Translate (0, -playerJumpMagnitude, 0);				
		} 		
	}
		
	
//	public void OnTriggerEnter (Collider collider)
//	{
//		if (collider.CompareTag ("hitter")) {
//			adjustCurrentHealth (healthChange);
//		}
//	}
//	
	void adjustCurrentHealth (int adj)
	{
		//print ("adjusting health");
		curHealth -= adj;
		healthBarLength = (Screen.width / 4.0f) * (curHealth / (float)maxHealth) + 100;
		
		if (curHealth <= 0) {
			Destroy (gameObject);
		}
	
	}
	
	public void damagePlayer()
	{
		//print ("entered damageplayer");
		adjustCurrentHealth ( healthChange );
	}
	
	public void  OnGUI ()
	{
		GUI.Box (new Rect (20.0f, 20.0f, healthBarLength, 20.0f), curHealth + "/" + maxHealth);
	}


}






